package com.matrix.framework.core.config;

import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;

/**
 * JWT密钥配置类
 *
 * Copyright © 海平面工作室 版权所有
 *
 * @Author: Leo
 * @Create: 2024/12/19 10:45
 * @Since 1.2
 */
@Configuration
@ConfigurationProperties(prefix = "matrix.jwt.key")
public class JwtKeyConfig {

    /**
     * 密钥轮换周期（天）
     */
    private int rotationDays = 30;

    /**
     * 密钥重叠期（天）- 新密钥生效后，旧密钥仍可使用的天数
     */
    private int overlapDays = 7;

    /**
     * 最大保留密钥数量
     */
    private int maxKeys = 3;

    /**
     * 是否启用密钥轮换
     */
    private boolean rotationEnabled = true;

    /**
     * 密钥轮换检查间隔（小时）
     */
    private int checkIntervalHours = 24;

    /**
     * 初始密钥（Base64编码）- 可选，如果不配置则自动生成
     */
    private String initialKey;

    /**
     * 密钥来源优先级
     * 1: 环境变量 MATRIX_JWT_INITIAL_KEY
     * 2: 配置文件 matrix.jwt.key.initial-key
     * 3: 自动生成
     */
    private String keySource = "auto";

    public int getRotationDays() {
        return rotationDays;
    }

    public void setRotationDays(int rotationDays) {
        this.rotationDays = rotationDays;
    }

    public int getOverlapDays() {
        return overlapDays;
    }

    public void setOverlapDays(int overlapDays) {
        this.overlapDays = overlapDays;
    }

    public int getMaxKeys() {
        return maxKeys;
    }

    public void setMaxKeys(int maxKeys) {
        this.maxKeys = maxKeys;
    }

    public boolean isRotationEnabled() {
        return rotationEnabled;
    }

    public void setRotationEnabled(boolean rotationEnabled) {
        this.rotationEnabled = rotationEnabled;
    }

    public int getCheckIntervalHours() {
        return checkIntervalHours;
    }

    public void setCheckIntervalHours(int checkIntervalHours) {
        this.checkIntervalHours = checkIntervalHours;
    }

    public String getInitialKey() {
        return initialKey;
    }

    public void setInitialKey(String initialKey) {
        this.initialKey = initialKey;
    }

    public String getKeySource() {
        return keySource;
    }

    public void setKeySource(String keySource) {
        this.keySource = keySource;
    }
} 